package com.zzyl.task;

import com.zzyl.service.ReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ReservationTask {

    @Autowired
    private ReservationService reservationService;

    /**
     * 每个小时的10分 和 40分 检查预约状态
     * 如果没有完成,就把状态改成过期-3
     */
    @Scheduled(cron = "0 10,40 * * * ?")
    public void cancelReservation() {
        log.info("定时任务开始执行");
        reservationService.overdue();
    }
}
